//
//  AboutProductViewController.m
//  QuickCure
//
//  Created by haoge on 16/9/10.
//  Copyright © 2016年 haoge. All rights reserved.
//

#import "AboutProductViewController.h"
#import <SVProgressHUD.h>

@interface AboutProductViewController ()<UITableViewDelegate,UITableViewDataSource>

@end

static NSString *indentifier = @"cell";

@implementation AboutProductViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupUI];
}

- (void)setupUI
{
    self.title = @"关于产品";
    
    //设置关于产品界面图标的大图
    UIImageView *bigImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"product_img_logo_nor.png"]];
    
    [self.view addSubview:bigImageView];
    
    [bigImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(50);
//        make.left.equalTo(self.view).offset(150);
//        make.right.equalTo(self.view).offset(-150);
        make.height.equalTo(@100);
        make.width.equalTo(@75);
        make.centerX.equalTo(self.view);
    }];
    
    //设置关于产品界面图标的小图
    UIImageView *smallImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"product_text_logo_nor.png"]];
    
    [self.view addSubview:smallImageView];
    
    [smallImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bigImageView.mas_bottom);
//        make.left.equalTo(self.view).offset(150);
//        make.right.equalTo(self.view).offset(-150);
        make.height.equalTo(@50);
        make.width.equalTo(@75);
        make.centerX.equalTo(self.view);
    }];
    
    //添加一个tableView
    UITableView *tableView = [[UITableView alloc] init];
    
    tableView.tableFooterView = [[UIView alloc] init];
    
    tableView.dataSource = self;
    
    tableView.delegate = self;
    
    [self.view addSubview:tableView];
    
    [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(smallImageView.mas_bottom).offset(30);
        make.trailing.leading.equalTo(self.view);
        make.height.equalTo(@45);
    }];
    
    //添加用户交流群信息
    UILabel *msgLabel = [[UILabel alloc] init];
    
    msgLabel.text = @"用户交流群: 4638375473";
    
    msgLabel.textColor = kThemeColor;
    
    [self.view addSubview:msgLabel];
    
    [msgLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerXWithinMargins.equalTo(self.view);
        make.bottom.equalTo(self.view).offset(@-100);
        make.height.equalTo(@30);
    }];
    
    //添加版本信息
    
    UILabel *versionLabel = [[UILabel alloc] init];
    
    versionLabel.text = @"version: 1.4.0";
    
    versionLabel.textColor = kThemeColor;
    
    [self.view addSubview:versionLabel];
    
    [versionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerXWithinMargins.equalTo(self.view);
        make.bottom.equalTo(self.view).offset(@-50);
        make.height.equalTo(@30);
    }];
    
    
}

#pragma mark -- 实现数据源方法 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:indentifier];
    
    if (!cell)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indentifier];
        
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    
    cell.imageView.image = [UIImage imageNamed:@"product_img_icon_xieyi.png"];
    
    cell.textLabel.text = @"用户协议";
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0)
    {
        [SVProgressHUD showSuccessWithStatus:@"打开协议"];
        
        [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeBlack];
        
        [SVProgressHUD setFadeInAnimationDuration:0.5];
        
        [SVProgressHUD setFadeOutAnimationDuration:0.5];
        
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [SVProgressHUD dismiss];
        });
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
